namespace sight {
    export class MainController extends hjc.Controller {
        public launchGame() {
            console.log("启动 sight")

            App.KeyBoard = new KeyBoard()
            App.KeyBoard.addEventListener(KeyBoard.onkeydown, function (e) {
                if (App.KeyBoard.isContain(e.data, KeyBoard.RightArrow)) {
                    console.debug("Key Right Begin")
                    game.notify(sight.ntf.KeyRightBegin)
                }
                if (App.KeyBoard.isContain(e.data, KeyBoard.keyArrow)) {
                    console.debug("Key Left Begin")
                    game.notify(sight.ntf.KeyLeftBegin)
                }
                if (App.KeyBoard.isContain(e.data, KeyBoard.UpArrow)) {
                    console.debug("Key Up Begin")
                    game.notify(sight.ntf.KeyUpBegin)
                }
                if (App.KeyBoard.isContain(e.data, KeyBoard.DownArrow)) {
                    console.debug("Key Down Begin")
                    game.notify(sight.ntf.KeyDownBegin)
                }
            }, null)

            App.KeyBoard.addEventListener(KeyBoard.onkeyup, function (e) {
                if (!App.KeyBoard.isContain(e.data, KeyBoard.RightArrow)) {
                    console.debug("Key Right End")
                    game.notify(sight.ntf.KeyRightEnd)
                }
                if (!App.KeyBoard.isContain(e.data, KeyBoard.keyArrow)) {
                    console.debug("Key Left End")
                    game.notify(sight.ntf.KeyLeftEnd)
                }
                if (!App.KeyBoard.isContain(e.data, KeyBoard.UpArrow)) {
                    console.debug("Key Up End")
                    game.notify(sight.ntf.KeyUpEnd)
                }
                if (!App.KeyBoard.isContain(e.data, KeyBoard.DownArrow)) {
                    console.debug("Key Down End")
                    game.notify(sight.ntf.KeyDownEnd)
                }
            }, null)

            game.enter(sight.GameScene)
        }
    }
}